/*
 * @Description:
 * @Version: 2.0
 * @Autor: wsh
 * @Date: 2023-06-20 16:06:20
 * @LastEditors: uphldjx 1373577124@qq.com
 * @LastEditTime: 2024-04-23 17:30:13
 */
import { uploadType } from '@/utils/util'
import { getStore } from '@/utils/store'
import { de } from 'element-plus/es/locale'

export const APPLI_TYPE = [
	{label:"报名",value:"0",type:"primary"},
	{label:"退出",value:"1",type:"danger"}
]

let userInfo = getStore('userInfo')
// 判断是服务商还是民政
let userType = 'govUser'
if(userInfo.classifyId==5){
	// 服务商
	userType = 'providerUser'
}else if(userInfo.classifyId==3){
	//民政用户
	userType = 'govUser'
}



// 列表
const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{ label: '培训名称', prop: 'trainingName' },
		// { label: '组织名称', prop: 'organizationName' },
		// { label: '组织单位', prop: 'createUserName' },
		{
			label: '培训类型',
			custome: 'tag',
			prop: 'trainingType',
			code: 'TRAIN_SUPER_TRAIN_TYPE',
			api: 'getDictItemList',
		},
		{ label: '从业人员姓名', prop: 'staffName' },
		{ label: '从业人员身份证号码', prop: 'idCard',plusXing: '2,2' },
		{ label: '手机号', prop: 'telphone',plusXing: '2,2' },
		{ 
			label: '报名状态',
			custome: 'tag',
			prop: 'status',
			dicData: APPLI_TYPE
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}


export const api = {
	index: 'view_bscTrainingSignUpRecord_page'
}
export const formateBuilData = (form) => {
	let query = {
		...form,
		buildInfo: undefined,
	}
	if (form.buildInfo && form.buildInfoText) {
		query.checkinBuilding = form.buildInfo[0]
		query.checkinFloor = form.buildInfo[1]
		query.checkinRoom = form.buildInfo[2]
		query.checkinBed = form.buildInfo[3]
	}
	return query
}

export const baseConfig = {
	pageName: '报名名单',
	// 数据字典
	dictcodes: [
		'LEAVEMANAGEMENT_LEAVE_TYPE',
		'BLOCK_CHAIN_STATUS',
		'JOB_TYPE',
		'punishmentLevel',
		'TRAINING_TYPE',
		'OCCUPATION_TYPE',
		'POSITION_TYPE',
		'REWARD_STATE',
		'HIRE_MODE',
		'WORK_TYPE',
		'HEALTHY_STATE',
		'NATURE',
		'SERVICE_STATE',
		'COMMON_FLAG',
		'ID_CARD_TYPE',
		'NATIONALITY',
		'POLITICAL_STATUS',
		'EDUCATION_DEGREE',
		'MARITAL_STATUS',
		'MARITAL_STATUS',
		'OCCUPATION_TYPE',
		'CERTIFICATE_CATEGORY',
		'PROOF_TYPE',
		'STAFF_MATERIAL_TYPE',
		'TRAIN_SUPER_TRAIN_TYPE'
	],
	rowKey: 'id',
	tipLabel: 'trainingName',
	addLabel: '制定培训单位',
	api: {
		...api
	},
	auth: {
		...api
	},
	menuAction: [
		{
			label: '预约入住',
			type: 'primary',
			operate: 'appoint',
			auth: 'view_dpElderlyCheckinRecord_page',
			show: false,
		},
	],
	// 当前行操作按钮
	menuBtn: [
		{
			label: '查看从业人员档案',
			type: 'primary',
			operate: 'detail',
			auth: api.index,
			text: true,
			show: true,
		},
	],

	dialogConfig: {
		width: '80%',
	},
	// 搜索
	searchConfig: {
		inline: true,
		showBtn: true,
		labelPosition: 'left',
		column: [
			{ label: '培训名称', prop: 'trainingName', type: 'input', span: 8 },
			{ label: '从业人员姓名', prop: 'staffName', type: 'input', span: 8 },
			{
				label: '身份证号',
				prop: 'idCard',
				span: 8,
			},
			{
				label: '报名状态',
				type: 'select',
				prop: 'status',
				propName: 'statusLabel',
				dicData: APPLI_TYPE,
				span: 8,
			},
			{
				label: '联系方式',
				prop: 'telphone',
				span: 8,
			},
			{
				label: '培训类型',
				prop: 'trainingLevel',
				propName: 'trainingLevelLabel',
				type: 'remoteSelect',
				code: 'TRAIN_SUPER_TRAIN_TYPE',
				api: 'getDictItemList',
				span: 8,
			},
		],
	},
	// 列表
	tableConfig,
	detailConfig: {
		inline: false,
		showBtn: false,
		labelPosition: 'left',
		column: [
		],
		customeHeader: {
			type: 'CardTwo',
			title: 'practitionersName',
			avatar: 'staffPhoto',
			tipList: [{ prop: 'phone', type: 'tip-success', label: '联系电话' }],
			tagList: [
				// { prop: 'healthyStateLabel', code: 'HEALTHY_STATE', custome: 'tag', type: 'success', label: '健康状态' },
				{ prop: 'workTypeLabel', code: 'WORK_TYPE', custome: 'tag', type: 'success', label: '工作类型' },
				{ prop: 'serviceStateLabel', code: 'SERVICE_STATE', custome: 'tag', type: 'success', label: '服务状态' },
				{ prop: 'unitName', type: 'success', label: '所在单位' },
			],
			
		},
	},

	onLoadFormate: async (arr) => {
		let tableData = arr.map((item) => {
			if(item.signUpStartTime&&item.signUpEndTime){
				item.signUpTime = [item.signUpStartTime,item.signUpEndTime]
			}
			return item
		})
		return Promise.resolve(tableData)
	},
	beforeOnLoadFormate(form) {
		// 处理搜索条件
		if(form.signUpTime){
			form.signUpStartTime = form.signUpTime[0]
			form.signUpEndTime = form.signUpTime[1]
			form.signUpTime = undefined
		}
		return new Promise((resolve, reject) => {
			resolve(form)
		})
	},
}
